﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SaleStat.COM.Exceptions;
using SaleStat.COM.Constant;

public partial class MasterPage : System.Web.UI.MasterPage
{
    #region 定数定义
    /// <summary>
    /// 定数定义_basaPage
    /// </summary>
    BasePage _basepage = new BasePage();

    /// <summary>
    /// 没有权限时显示样式
    /// </summary>
    private const string CSS_MENU_DISABLE = "background:url('../Images/mnudisbtn.png') no-repeat 0px 0px;";
    #endregion

    #region 事件方法
    #region  初始化
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                //获取用户登入信息
                getLoginInfo();
            }
        }
        catch (Exception ex)
        {
            _basepage.ExceptionHandler(ex);

        }
    }
    #endregion

    #region 重新登录事件
    /// <summary>
    /// 重新登录按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkBtnMenu_Click(object sender, EventArgs e)
    {
        try
        {
            //清空session
            Session.Abandon();
            Response.Redirect("~/Login.aspx", false);
        }
        catch (Exception ex)
        {

            _basepage.ExceptionHandler(ex);
        }
    }
    #endregion

    #region 产品管理按钮点击事件
    /// <summary>
    /// 产品管理按钮点击事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkBtnProcutManage_Click(object sender, EventArgs e)
    {
        try
        {
            Response.Redirect("~/PM/PM_List.aspx", false);
        }
        catch (Exception ex)
        {
            _basepage.ExceptionHandler(ex);
        }
    }
    #endregion

    #region 客户管理按钮点击事件
    /// <summary>
    /// 客户管理按钮点击事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkBtnCustomManage_Click(object sender, EventArgs e)
    {
        try
        {
            //跳转到客户管理页面
            Response.Redirect("~/CM/CM001F001.aspx", false);
        }
        catch (Exception ex)
        {
            _basepage.ExceptionHandler(ex);

        }
    }
    #endregion

    #region 销售统计管理点击事件
    /// <summary>
    /// 销售统计管理点击事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkBtnSellInfoManage_Click(object sender, EventArgs e)
    {
        try
        {
            //跳转到销售管理页面
            Response.Redirect("~/SM/SM_list.aspx", false);
        }
        catch (Exception ex)
        {
            _basepage.ExceptionHandler(ex);
        }
    }
    #endregion

    #region 用户管理点击事件
    /// <summary>
    /// 用户管理
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lnkBtnUserManage_Click(object sender, EventArgs e)
    {
        try
        {
            //跳转到用户管理页面
            Response.Redirect("~/PS/PS001F001.aspx", false);
        }
        catch (Exception ex)
        {
            _basepage.ExceptionHandler(ex);
        }
    }
    #endregion
    #endregion

    #region 自定义方法

    #region 获取loginInfo
    protected void getLoginInfo()
    {
        //设置系统时间
        string strCurrentTime = System.DateTime.Now.Year.ToString() + "年" + System.DateTime.Now.Month.ToString() + "月" +
            System.DateTime.Now.Day.ToString() + "日";
        string strWeekDay = System.DateTime.Now.DayOfWeek.ToString();
        switch (strWeekDay)
        {

            case "Monday":
                strCurrentTime = strCurrentTime + "星期一";
                break;
            case "Tuesday":
                strCurrentTime = strCurrentTime + "星期二";
                break;
            case "Wednesday":
                strCurrentTime = strCurrentTime + "星期三";
                break;
            case "Thursday":
                strCurrentTime = strCurrentTime + "星期四";
                break;
            case "Friday":
                strCurrentTime = strCurrentTime + "星期五";
                break;
            case "Saturday":
                strCurrentTime = strCurrentTime + "星期六";
                break;
            case "Sunday":
                strCurrentTime = strCurrentTime + "星期天";
                break;
        }
        //设置时间
        lblSystemTime.Text = strCurrentTime;
        //设置用户姓名
        lblUserName.Text = Session[SessionKeyConstant.SESSION_USERNAME].ToString();
        string StrPuriview = Session[SessionKeyConstant.SESSION_PURVIEW].ToString();
        //设置用户权限
        lblPurview.Text = StrPuriview;
        if (("销售员").Equals(StrPuriview))
        {
            //客户管理不显示
            lnkBtnCustomManage.Enabled = false;
            lnkBtnCustomManage.Attributes.Add("style", CSS_MENU_DISABLE);
            //产品管理不显示
            lnkBtnProcutManage.Enabled = false;
            lnkBtnProcutManage.Attributes.Add("style", CSS_MENU_DISABLE);
            //用户管理不显示
            lnkBtnUserManage.Enabled = false;
            lnkBtnUserManage.Attributes.Add("style", CSS_MENU_DISABLE);

        }
    }
    #endregion

    #endregion
}
